package org.sandbox2.service;

import org.sandbox2.domain.bank.Account;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountService {
	
	@Transactional
	public void tranfer(Integer amount, Long fromId, Long toId) {
		
		System.out.println("AccountService#tranfer");
		
		Account from = Account.findAccount(fromId);
		Account to = Account.findAccount(toId);
		
		to.deposit(amount);	
		from.withdraw(amount);

	}
}
